package com.zx.rbac.ums.controller;

import java.util.Map;

import com.zx.rbac.common.api.Result;
import com.zx.rbac.ums.model.dto.UmsAdminDto;
import com.zx.rbac.ums.model.UmsAdminEntity;
import com.zx.rbac.ums.model.mapstruct.UmsAdminBeanMapper;
import com.zx.rbac.ums.model.vo.UmsAdminVo;
import com.zx.rbac.ums.service.UmsAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 * 管理员相关接口
 */
@RestController
@RequestMapping("rbacApi/umsadmin")
public class UmsAdminController {

    @Autowired
    private UmsAdminService umsAdminService;

    /**
     * 登录
     * @return
     */
    @RequestMapping("/login")
    public Result<UmsAdminVo> login(@RequestBody @Validated UmsAdminDto adminDto){
        UmsAdminDto dto = umsAdminService.login(adminDto);
        UmsAdminVo vo = UmsAdminBeanMapper.INSTANCE.dtoTOvo(dto);
        return Result.success(vo);
    }

    /**
     * 账户添加
     */
    @RequestMapping("/add")
    public Result<UmsAdminVo> add(@RequestBody @Validated UmsAdminDto adminDto){
        umsAdminService.add(adminDto);
        return Result.success();
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("rbacApi:umsadmin:list")
    public Result list(@RequestParam Map<String, Object> params){
        return Result.success();
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("rbacApi:umsadmin:info")
    public Result info(@PathVariable("id") Long id){
        return Result.success();
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("rbacApi:umsadmin:save")
    public Result save(@RequestBody UmsAdminEntity umsAdmin){
        return Result.success();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("rbacApi:umsadmin:update")
    public Result update(@RequestBody UmsAdminEntity umsAdmin){
        return Result.success();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("rbacApi:umsadmin:delete")
    public Result delete(@RequestBody Long[] ids){
        return Result.success();
    }

}
